package com.fenghao.subject.infra.basic.service.impl;

import com.alibaba.fastjson.JSON;
import com.fenghao.subject.infra.basic.entity.SubjectCategory;
import com.fenghao.subject.infra.basic.mapper.SubjectCategoryDao;
import com.fenghao.subject.infra.basic.service.SubjectCategoryService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * SubjectCategoryServiceImpl
 */
@Service("subjectCategoryService")
@Slf4j

public class SubjectCategoryServiceImpl implements SubjectCategoryService {
    @Resource
    private SubjectCategoryDao subjectCategoryDao;

    /**
     * 新增数据
     */
    public int insert(SubjectCategory subjectCategory) {
        if (log.isInfoEnabled()) {
            // 序列化入参 subjectCategory 并打印日志
            log.info("SubjectCategoryController.add.subjectCategory:{}", JSON.toJSONString(subjectCategory));
        }
        return subjectCategoryDao.insert(subjectCategory);
    }

    /**
     * 通过主键删除数据
     */
    @Override
    public boolean deleteById(Long id) {
        return this.subjectCategoryDao.deleteById(id) > 0;
    }

    /**
     * 修改数据
     */
    @Override
    public int update(SubjectCategory subjectCategory) {
        return subjectCategoryDao.update(subjectCategory);
    }

    /**
     * 通过ID查询单条数据
     */
    @Override
    public SubjectCategory queryById(Long id) {
        this.subjectCategoryDao.queryById(id);
        return this.subjectCategoryDao.queryById(id);
    }

    /**
     * 查询岗位分类
     */
    @Override
    public List<SubjectCategory> queryCategory(SubjectCategory subjectCategory) {
        return subjectCategoryDao.queryCategory(subjectCategory);
    }


}
